Skip to content

Fix deleted modifier-only primary shortcuts staying active( #498 )#503

Open
Yaomeng1749 wants to merge 5 commits into
altic-dev:mainfrom
Yaomeng1749:codex/fix-498-primary-shortcut-reset
Open

Fix deleted modifier-only primary shortcuts staying active( #498 )#503
Yaomeng1749 wants to merge 5 commits into
altic-dev:mainfrom
Yaomeng1749:codex/fix-498-primary-shortcut-reset

Conversation

@Yaomeng1749

@Yaomeng1749 Yaomeng1749 commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Fixes #498.

Clears stale Primary Dictation hotkey press state when the primary shortcut list changes. This prevents a deleted modifier-only primary shortcut from keeping a pending hold/tap path active until app restart.

Changes

  • Track removed primary shortcuts in updatePrimaryShortcuts(_:).
  • Clear/cancel matching primary dictation runtime state for removed primary shortcuts.
  • Keep event tap teardown as a force-clear path.
  • Add a regression test for deleting a modifier-only primary shortcut while its hold start is pending.

Testing

Local:

swiftformat --config .swiftformat Sources/Fluid/Services/GlobalHotkeyManager.swift Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
swiftformat --lint --config .swiftformat Sources/Fluid/Services/GlobalHotkeyManager.swift Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
git diff --check
xcrun swiftc -parse Sources/Fluid/Services/GlobalHotkeyManager.swift Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
swiftlint --strict --config .swiftlint.yml

GitHub Actions, same head c2caabd26d8c2a50daa6f061e78449aa233d8d5e:

Upstream Actions are awaiting maintainer approval for the public-fork workflow.

@Yaomeng1749

Yaomeng1749 commented Jul 1, 2026

Copy link
Copy Markdown
Author

Final verification for c2caabd26d8c2a50daa6f061e78449aa233d8d5e:

  • Added a regression test for deleting a modifier-only Primary Dictation shortcut while its hold start is pending.
  • Local Xcode 26.6: swiftlint --strict --config .swiftlint.yml passed with 0 violations.
  • Fork CI on the same head passed: https://github.com/Yaomeng1749/FluidVoice/actions/runs/28551228981
  • CI covered SwiftLint, dependency resolution, build, and tests.
  • Upstream Actions are still waiting for maintainer approval for the public-fork workflow.

@Yaomeng1749 Yaomeng1749 marked this pull request as ready for review July 1, 2026 21:41
@Yaomeng1749 Yaomeng1749 changed the title Fix deleted modifier-only primary shortcuts staying active Fix deleted modifier-only primary shortcuts staying active( #498 ) Jul 4, 2026
@altic-dev

Copy link
Copy Markdown
Owner

Thanks for the PR. Actually, very useful PR, and thanks for finding the bug as well, but I think there is one comment that I have for you. Let me know what you think. If you think this is valid, then you can probably fix it for me and then you can merge it .

"active primary press matching only uses keyCode/button. If two primary shortcuts share the same key/button with different modifiers, deleting the inactive one can clear the active held one, so release may not stop recording. Fix: store/compare the active HotkeyShortcut including modifiers."

@Yaomeng1749

Copy link
Copy Markdown
Author

Thanks, I think this is valid.

The current cleanup path identifies the active primary press by key/button only, which is fine for pairing the release event, but too broad for deciding whether a removed shortcut is the active one. With two primary shortcuts sharing the same key/button but different modifiers, removing the inactive one could clear the active press.

I’ll update the active primary press state to keep the matched HotkeyShortcut and use that full shortcut, including modifiers, when comparing against removed shortcuts. I’ll keep the release path tolerant of modifier changes on key-up, but make the removal cleanup use the full shortcut identity. I’ll also add a regression test for the shared key/button + different modifiers case.

@Yaomeng1749

Copy link
Copy Markdown
Author

Implemented this in 55a469d2946f3c0f8d2837476cb4aa4731afb2b0.

The active primary press now snapshots the matched shortcut identity, including modifiers, for removal matching. Key-up / mouse-up still only match the released key/button so releasing modifiers before the main key remains supported.

I also added a regression test for the shared-key case: Command+K active, Option+K removed. The active press is preserved and the later K release clears it.

Local checks:

  • swiftformat --lint --config .swiftformat Sources/Fluid/Services/GlobalHotkeyManager.swift Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
  • git diff --check
  • xcrun swiftc -parse Sources/Fluid/Services/GlobalHotkeyManager.swift Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
  • swiftlint --strict --config .swiftlint.yml
  • targeted xcodebuild test for FluidDictationIntegrationTests/GlobalHotkeyManagerShortcutTests: 2 passed, 0 failed on macOS/My Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Deleted modifier-only primary shortcut remains active until app restart

2 participants